package thread;

/**
 * 静态方法如果使用了Synchronized ，那么该方法一定具有同步（干了这个在干那个）效果
 */
public class SynDemo3 {
    public static void main(String[] args) {
//        FooP f = new FooP();
//        FooP f1 = new FooP();
        Thread t = new Thread(){
            @Override
            public void run() {
                FooP.dosome();
            }
        };
        Thread t1 = new Thread(){
            @Override
            public void run() {
                FooP.dosome();
            }
        };
        t.start();
        t1.start();
    }
}
class FooP{
    public synchronized  static void dosome(){
        try {
            Thread thread = Thread.currentThread();
            System.out.println(thread.getName()+":执行！！");
            Thread.sleep(5000);
            System.out.println(thread.getName()+":执行完毕！");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
